full test coverage#289
Conversation
| case '+': | ||
| return firstValue + secondValue; | ||
| case '-': | ||
| return firstValue - secondValue; | ||
| case '*': | ||
| return firstValue * secondValue; | ||
| case '/': |
There was a problem hiding this comment.
Make constants for operations chars.
| if (secondValue == Double.MIN_VALUE) { | ||
| throw new IllegalValueException("can`t resolve operation"); | ||
| } |
There was a problem hiding this comment.
Why do you need this Exception? Raising with MIN_VALUE is corectly work, as with ZERO.
There was a problem hiding this comment.
it return NuN not 0. Look at this screen ->
https://prnt.sc/1s5kqe1
| @BeforeEach | ||
| void setUp() { | ||
| calculator = new Calculator(); | ||
| } |
There was a problem hiding this comment.
I think will be better use BeforeAll method. It's redundant Initialize "calculator" before each test.
| void addTwoPositiveOk() { | ||
| double firstValue = 5; | ||
| double secondValue = 1; | ||
| double actual = calculator.calculate(firstValue, secondValue, '+'); |
There was a problem hiding this comment.
The same with chars, initialize constant for '+' and other operations. You can use "refactor -> introduce field" for change it for all class)
| double firstValue = -5; | ||
| double secondValue = -1; | ||
| double actual = calculator.calculate(firstValue, secondValue, '+'); | ||
| double expected = -6; |
There was a problem hiding this comment.
Move this variables to fields, and initialize them in method.
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <version>${junit-jupiter.version}</version> | ||
| <version>5.8.0-RC1</version> |
There was a problem hiding this comment.
RC means Release Candidate, it could be not stable, try to avoid using RC versions
| if (secondValue == Double.MIN_VALUE) { | ||
| throw new IllegalValueException("can`t resolve operation"); | ||
| } |
| } | ||
|
|
||
| @Test | ||
| void checkOperatorNotOk() { |
There was a problem hiding this comment.
Let's name our methods based on the pattern <methodUnderTest>_<state>_<expectedBehavior>

No description provided.